# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=rext
pkgver=63.5f0f626
pkgrel=11
groups=('blackarch' 'blackarch-exploitation' 'blackarch-scanner')
pkgdesc='Router EXploitation Toolkit - small toolkit for easy creation and usage of various python scripts that work with embedded devices.'
arch=('any')
url='https://github.com/j91321/rext'
license=('GPL3')
depends=('python' 'python-requests' 'python-requestsexceptions'
         'python-paramiko' 'python-beautifulsoup4')
makedepends=('git')
source=("git+https://github.com/j91321/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  sed -i '5d' "$pkgname.py"
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md \
    requirements.txt
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm README.md LICENSE

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python $pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

